<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>服务设置</title>  
</head>
<body>
<div  style="text-align:left;">
<!-- 	<div class="ui segment" style="background-color: #152b52;margin:0rem;font-size:16px;" id="tab1">
	  <div class="ui inverted secondary menu" >
	     <button class="item" onclick="create();" >添加服务项目(最多4个服务项大类) </button> 
	  </div> 
	</div> -->
	<div class="ui middle aligned divided list"  style="background-color:#fff;margin:0rem;padding:1rem;display:block;">
	<c:choose>
		<c:when test="${desclist != null && fn:length(desclist)>0}">
		<c:forEach items="${desclist}" var="desc">
  				<div class="position" data-position-id="${desc.id}">
					<div class="list">
						<h5 class="list_title">
							${desc.tag}
						</h5>
						<p class="list_content content">￥${desc.spec}/${desc.unit}(${desc.name})</p>
					</div>
	               <%-- <button class="ui button active" onclick="update(${desc.id});" style="background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">修改</button> --%>
	               <c:if test="${desc.status==0}">
	               	<button class="ui button active" onclick="publish(${desc.id});" style="background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">发布</button>
	               </c:if>
	               <c:if test="${desc.status==1}">
	               	<button class="ui button active" onclick="unpublish(${desc.id});" style="background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">下线</button>
	               </c:if>
	               <button class="ui button active" onclick="del(${desc.id});" style="background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">删除</button>
				</div>
				 <hr class="hrtext"/>
				</c:forEach>    </c:when>
		<c:otherwise>
			 您暂无没有相关服务项目信息！
		</c:otherwise>
	</c:choose>
	</div>
	
<script src="${ctx}/resources/jweixin-1.0.0.js"></script>
<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js"type="text/javascript"></script>
<script type="text/javascript">
	function create(){
		var getUrl = '${ctx}/wechat/hunter/toCreateDesc.page';
		location.href = getUrl;
	}
	
	function del(id){
		var getUrl = '${ctx}/wechat/hunter/delDesc.do';
		var param = {};
		var ordescId = id;
		console.log(ordescId);
		param['ordescId'] = ordescId;
        $.ajax({ 
            url: getUrl, 
            type: "GET", 
            data : param,
            success : function(data) {
				alert(data.msg);
				window.location.reload();
			},
			error : function() {
				alert("服务出错，请稍后尝试");
			}
    });
	}
	
	function unpublish(id){
		var getUrl = '${ctx}/wechat/hunter/updStatusDesc.do';
		var param = {};
		var ordescId = id;
		console.log(ordescId);
		param['ordescId'] = ordescId;
		param['status'] = 0;
        $.ajax({ 
            url: getUrl, 
            type: "GET", 
            data : param,
            success : function(data) {
				alert(data.msg);
				window.location.reload()
			},
			error : function() {
				alert("服务出错，请稍后尝试");
			}
    });
	}

	function publish(id){
		var getUrl = '${ctx}/wechat/hunter/updStatusDesc.do';
		var param = {};
		var ordescId = id;
		console.log(ordescId);
		param['ordescId'] = ordescId;
		param['status'] = 1;
        $.ajax({ 
            url: getUrl, 
            type: "GET", 
            data : param,
            success : function(data) {
				alert(data.msg);
				window.location.reload();
			},
			error : function() {
				alert("服务出错，请稍后尝试");
			}
    });
	}
	
	function update(id){
		var getUrl = '${ctx}/wechat/hunter/toEditDesc.page';
		getUrl += '?ordescId=' + id;
		location.href = getUrl;
	}
	
    $(document).ready(function() {  
            wx.ready(function() {
            wx.onMenuShareAppMessage({
                title: 'Headoffer--专业招聘平台----推荐有奖！',  
                desc: '搭起企业和专业猎头的桥梁，为企业招募英才。',  
                link: 'http://www.tiaonali.com${ctx}/wechat/hunter/shareservice.page',  
                imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg',  
                type: 'link'
            });

            wx.onMenuShareTimeline({
                title: 'Headoffer--专业招聘平台----推荐有奖！',  
                desc: '搭起企业和专业猎头的桥梁，为企业招募英才。',  
                link: 'http://www.tiaonali.com${ctx}/wechat/hunter/shareservice.page',  
                imgUrl: 'http://www.tiaonali.com${ctx}/resources/images/sharelogo.jpg'
            });

            wx.showOptionMenu();
            
        });
        
    });
</script>

</body>
</html>